package cn.school.thoughtworks.section1;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class PracticeA {

    List<String> collectSameElements(List<String> collection1, List<String> collection2) {

        List<String>  collection3 = new ArrayList<String>();
        HashSet<String> hashSet = new HashSet<String>();

        for (String s :  collection2) {
            hashSet.add(s);
        }
        for (String s :  collection1) {
            if(hashSet.add(s)==false){
                collection3.add(s);
            }
        }


        return  collection3;

    }




}